package com.sumainfor.common.util;

import com.alibaba.fastjson.JSONObject;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sun.security.krb5.internal.crypto.Des;

import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.*;

/**
 * 唐巢&通通锁开放平台
 * @ClassName: InteDeviceLockUtil
 * @author xzzhao
 * @date 2019年3月11日
 */
public class InteDeviceLockUtil {
    private static Logger  log = LoggerFactory.getLogger(InteDeviceLockUtil.class);// 日志


    /**
     *获取时间戳
     */
    public static String getTimeSign () {
        //北京时间
        ZoneOffset zoneOffset=ZoneOffset.ofHours(8);
        //初始化LocalDateTime对象
        LocalDateTime localDateTime=LocalDateTime.now();
        //获取LocalDateTime对象对应时区的Unix时间戳
        System.out.println(localDateTime.toEpochSecond(zoneOffset));

        return  String.valueOf(localDateTime.toEpochSecond(zoneOffset))+"000";
    }
    /*
     *获取某段时间之后的一段时间
     */
    public static String getTimeAfter (long currentTime,int millisecond,String dateForMatter) {
        //yyyy-MM-dd HH:mm:ss 格式
        SimpleDateFormat dateFormat = new SimpleDateFormat(dateForMatter);
        //毫秒时间
        currentTime +=millisecond;
        Date date=new Date(currentTime);
        System.out.println("格式化后输出时间:"+dateFormat.format(date));
        return  dateFormat.format(date);
    }
    /**
     *获取时间戳
     */
    public static String getTimeSign (String date,String dateForMatter) {
        if (date.equals("") || dateForMatter.equals("") ){
            return null;
        }
        DateTimeFormatter df = DateTimeFormatter.ofPattern(dateForMatter);
        //初始化LocalDateTime对象
        LocalDateTime localDateTime = LocalDateTime.parse(date,df);
        //北京时间
        ZoneOffset zoneOffset=ZoneOffset.ofHours(8);
        //获取LocalDateTime对象对应时区的Unix时间戳
        System.out.println(String.valueOf(localDateTime.toEpochSecond(zoneOffset))+"000");
        return  String.valueOf(localDateTime.toEpochSecond(zoneOffset))+"000";
    }
    /**
     * 获取访问令牌
     * @param param
     * @return
     */
    public static Map<String,Object> oauth2Token(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/oauth2/token";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 分页获取名下的锁列表
     * @param param
     * @return
     */
    public static Map<String,Object> lockList(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/list";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁的普通钥匙列表
     * @param param
     * @return
     */
    public static Map<String,Object> lockListKey(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/listKey";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁的详情
     * @param param
     * @return
     */
    public static Map<String,Object> lockDetail(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/detail";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除所有普通钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> lockDeleteAllKey(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/deleteAllKey";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁的键盘密码列表
     * @param param
     * @return
     */
    public static Map<String,Object> listKeyboardPwd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/listKeyboardPwd";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改锁管理员键盘密码
     * @param param
     * @return
     */
    public static Map<String,Object> changeAdminKeyboardPwd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/changeAdminKeyboardPwd";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改锁的清空密码
     * @param param
     * @return
     */
    public static Map<String,Object> changeDeletePwd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/changeDeletePwd";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改锁名称
     * @param param
     * @return
     */
    public static Map<String,Object> rename(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/rename";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 重置普通钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> resetKey(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/resetKey";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 重置键盘密码
     * @param param
     * @return
     */
    public static Map<String,Object> resetKeyboardPwd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/resetKeyboardPwd";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁的键盘密码版本
     * @param param
     * @return
     */
    public static Map<String,Object> getKeyboardPwdVersion(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/getKeyboardPwdVersion";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 上传锁的电量
     * @param param
     * @return
     */
    public static Map<String,Object> updateElectricQuantity(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/updateElectricQuantity";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 更新锁的特征值
     * @param param
     * @return
     */
    public static Map<String,Object> updateSpecialValue(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/updateSpecialValue";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 转移锁
     * @param param
     * @return
     */
    public static Map<String,Object> transfer(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/transfer";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 查询锁电量
     * @param param
     * @return
     */
    public static Map<String,Object> queryElectricQuantity(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/queryElectricQuantity";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 发送钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> keySend(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/send";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 同步钥匙数据
     * @param param
     * @return
     */
    public static Map<String,Object> keySyncData(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/syncData";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除电子钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> keyDelete(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/delete";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 冻结钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> keyFreeze(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/freeze";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 解冻钥匙
     * @param param
     * @return
     */
    public static Map<String,Object> keyUnfreeze(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/unfreeze";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改钥匙有效期
     * @param param
     * @return
     */
    public static Map<String,Object> keyChangePeriod(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/changePeriod";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     *  钥匙授权
     * @param param
     * @return
     */
    public static Map<String,Object> keyAuthorize(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/authorize";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 解除钥匙授权
     * @param param
     * @return
     */
    public static Map<String,Object> keyUnauthorize(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/key/unauthorize";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取键盘密码 （PDF文档这个接口的描述有问题少了个）
     * @param param
     * @return
     */
    public static Map<String,Object> keyboardPwdGet(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/keyboardPwd/get";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除单个键盘密码
     * @param param
     * @return
     */
    public static Map<String,Object> keyboardPwdDelete (Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/keyboardPwd/delete";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改单个键盘密码
     * @param param
     * @return
     */
    public static Map<String,Object> keyboardPwdChange  (Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/keyboardPwd/change";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 添加键盘密码
     * @param param
     * @return
     */
    public static Map<String,Object> keyboardPwdAdd (Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/keyboardPwd/add";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取用户主键
     * @param param
     * @return
     */
    public static Map<String,Object> userGetUid(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/user/getUid";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 读取锁的时间
     * @param param
     * @return
     */
    public static Map<String,Object> queryDate(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/queryDate";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 校准锁的时间
     * @param param
     * @return
     */
    public static Map<String,Object> updateDate(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/updateDate";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 开锁
     * @param param
     * @return
     */
    public static Map<String,Object> unlock(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/unlock";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 冻结锁
     * @param param
     * @return
     */
    public static Map<String,Object> freeze(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/freeze";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 解冻锁
     * @param param
     * @return
     */
    public static Map<String,Object> unfreeze(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/unfreeze";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 查询锁的冻结状态
     * @param param
     * @return
     */
    public static Map<String,Object> queryStatus(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/queryStatus";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取名下网关列表
     * @param param
     * @return
     */
    public static Map<String,Object> gatewayList(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/gateway/list";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除网关
     * @param param
     * @return
     */
    public static Map<String,Object> gatewayDelete(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/gateway/delete";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取网关管理的锁列表
     * @param param
     * @return
     */
    public static Map<String,Object> gatewayListLock(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/gateway/listLock";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 查询某网关是否初始化成功
     * @param param
     * @return
     */
    public static Map<String,Object> gatewayIsInitSuccess (Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/gateway/isInitSuccess";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁名下IC卡列表
     * @param param
     * @return
     */
    public static Map<String,Object> identityCardList (Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/identityCard/list";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 添加IC卡
     * @param param
     * @return
     */
    public static Map<String,Object> identityCardAdd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/identityCard/add";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除IC卡
     * @param param
     * @return
     */
    public static Map<String,Object> identityCardDelete(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/identityCard/delete";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 清空IC卡
     * @param param
     * @return
     */
    public static Map<String,Object> identityCardClear(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/identityCard/clear";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 修改IC卡有效期
     * @param param
     * @return
     */
    public static Map<String,Object> changePeriod(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/identityCard/changePeriod";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取锁名下的指纹列表
     * @param param
     * @return
     */
    public static Map<String,Object> fingerprintList(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/fingerprint/list";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 添加指纹
     * @param param
     * @return
     */
    public static Map<String,Object> fingerprintAdd(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/fingerprint/add";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 删除指纹
     * @param param
     * @return
     */
    public static Map<String,Object> fingerprintDelete(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/fingerprint/delete";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 清空指纹
     * @param param
     * @return
     */
    public static Map<String,Object> fingerprintClear(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/fingerprint/clear";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 获取记录列表
     * @param param
     * @return
     */
    public static Map<String,Object> lockRecordList(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lockRecord/list";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 上传锁记录
     * @param param
     * @return
     */
    public static Map<String,Object> lockRecordUpload(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lockRecord/upload";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 检查锁固件是否需要升级
     * @param param
     * @return
     */
    public static Map<String,Object> upgradeCheck(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/upgradeCheck";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }

    /**
     * 再次检测固件是否需要升级
     * @param param
     * @return
     */
    public static Map<String,Object> upgradeRecheck(Map<String,Object> param) {
        // 装配请求参数
        String url="https://api.ttlock.com.cn/v3/lock/upgradeRecheck";
        //发送请求
        Map<String,Object> params=HttpUtilBee.doPostParams(url,param);
        System.out.println("返回的参数:"+params);
        return params;
    }


    public static void main(String[] args) {
        /*获取访问令牌*/
//        Map<String,Object> params=new HashMap<String, Object>();
//        params.put("client_id",InteDeviceLockConfig.CLIENT_ID);
//        params.put("client_secret",InteDeviceLockConfig.CLIENT_SECRET);
//        params.put("grant_type",InteDeviceLockConfig.GRANT_TYPE_PASSWORD);
//        params.put("username",InteDeviceLockConfig.USERNAME);
//        params.put("password",InteDeviceLockConfig.PASSWORD);
//        params.put("redirect_uri",InteDeviceLockConfig.REDIRECT_URL);
//        InteDeviceLockUtil.oauth2Token(params);
        /*分页获取名下的锁列表*/
//          Map<String,Object> params=new HashMap<String, Object>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date",InteSameCityUtil.getTimeSign());
//        InteDeviceLockUtil.lockList(params);
            /*获取锁的普通 钥匙列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1554345800000");
//        params.put("lockId","3854");
//        InteDeviceLockUtil.lockListKey(params);
        /*获取锁的详情*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","42637");
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.lockDetail(params);
        /*获取所有普通钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.lockDeleteAllKey(params);
        /*获取锁的键盘密码列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.listKeyboardPwd(params);
        /*修改锁管理员键盘密码*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("password",InteDeviceLockConfig.PASSWORD);
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.changeAdminKeyboardPwd(params);
        /*修改锁的清空密码*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("password",InteDeviceLockConfig.PASSWORD);
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.changeDeletePwd(params);
        /*修改锁名称*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("lockAlias","11");
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.rename(params);
        /*重置普通钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552549016000");
//        InteDeviceLockUtil.resetKey(params);
        /*重置普通钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("pwdInfo","111");
//        params.put("timestamp","111");
//        params.put("date","1552550669000");
//        InteDeviceLockUtil.resetKeyboardPwd(params);
        /*获取锁的键盘密码版本*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552550669000");
//        InteDeviceLockUtil.getKeyboardPwdVersion(params);
        /*上传锁的电量*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("electricQuantity","1");
//        params.put("date","1552550669000");
//        InteDeviceLockUtil.updateElectricQuantity(params);
        /*更新锁的特征值*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("specialValue","1");
//        params.put("date","1552550669000");
//        InteDeviceLockUtil.updateSpecialValue(params);
        /*转移锁*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("receiverUsername","1");
//        params.put("lockIdList","[123,123]");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.transfer(params);
        /*查询锁电量*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.queryElectricQuantity(params);
        /*发送钥匙*/
        Map<String,Object> params=new HashMap<String, Object>();
        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
        params.put("lockId","7081");
        params.put("receiverUsername","13183302095");
        params.put("startDate",InteDeviceLockUtil.getTimeSign("2019-07-08","yyyy-MM-dd"));
        params.put("endDate",InteDeviceLockUtil.getTimeSign("2019-07-09","yyyy-MM-dd"));
        params.put("remarks","1");
        params.put("remoteEnable","1");
        params.put("date",InteDeviceLockUtil.getTimeSign());
        System.out.println("params："+params);
        InteDeviceLockUtil.keySend(params);
        /*同步钥匙数据*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lastUpdateDate","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keySyncData(params);
        /*删除电子钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("keyId","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyDelete(params);
        /*冻结钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("keyId","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyFreeze(params);
        /*解冻钥匙*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("keyId","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyUnfreeze(params);


        /*修改钥匙有效期*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("keyId","1");
//        params.put("date","1552551139000");
//        params.put("startDate","1");
//        params.put("endDate","1552551139000");
//        InteDeviceLockUtil.keyChangePeriod(params);
        /*钥匙授权*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552551139000");
//        params.put("keyId","1");
//        InteDeviceLockUtil.keyAuthorize(params);
        /*解除钥匙授权*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552551139000");
//        params.put("keyId","1");
//        InteDeviceLockUtil.keyUnauthorize(params);
            /*获取键密码*/
//        Map<String,Object> params=new HashMap<String, Object>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","42637");
//        params.put("keyboardPwdVersion","4");
//        params.put("keyboardPwdType","1");
//        params.put("startDate",InteDeviceLockUtil.getTimeSign("2019-05-31 12:07:05","yyyy-MM-dd HH:mm:ss"));
//        params.put("endDate",InteDeviceLockUtil.getTimeSign("2019-06-29 17:07:05","yyyy-MM-dd HH:mm:ss"));
//        params.put("date",InteDeviceLockUtil.getTimeSign());
//        InteDeviceLockUtil.keyboardPwdGet(params);

        /*删除单个键盘密码*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("keyboardPwdId","4");
//        params.put("deleteType","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyboardPwdDelete(params);
        /*修改键盘密码*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("keyboardPwdId","4");
//        params.put("newKeyboardPwd","1");
//        params.put("startDate","4");
//        params.put("endDate","1");
//        params.put("changeType","4");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyboardPwdChange(params);
        /*添加键盘密码*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("keyboardPwd","4");
//        params.put("keyboardPwdName","1");
//        params.put("startDate","4");
//        params.put("endDate","1");
//        params.put("addType","1");
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.keyboardPwdAdd(params);
        /*获取用户主键*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("date","1552551139000");
//        InteDeviceLockUtil.userGetUid(params);
        /*读取锁的时间*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.queryDate(params);
        /*校准锁的时间*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.updateDate(params);
        /*开锁*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.unlock(params);
        /*冻结锁*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.freeze(params);
        /*冻结锁*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.unfreeze(params);

        /*查询锁的冻结状态*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555163000");
//        InteDeviceLockUtil.queryStatus(params);
        /*获取名下网关列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.gatewayList(params);
        /*删除网关*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("gatewayId","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.gatewayDelete(params);
        /*获取网关管理的锁列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("gatewayId","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.gatewayListLock(params);

        /*查询某网关是否初始化成功*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("gatewayNetMac","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.gatewayIsInitSuccess(params);

        /*获取锁名下的IC卡列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.identityCardList(params);
            /*添加IC卡*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("cardNumber","1");
//        params.put("cardName","1");
//        params.put("startDate","1");
//        params.put("endDate","1");
//        params.put("addType0.","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.identityCardAdd(params);

        /*添加IC卡*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("cardId","1");
//        params.put("deleteType","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.identityCardDelete(params);

        /*清空IC卡*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.identityCardClear(params);
        /*修改IC卡有效期*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("cardId","1");
//        params.put("startDate","1");
//        params.put("endDate","1");
//        params.put("changeType","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.changePeriod(params);
        /*获取锁名下的指纹列表*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.fingerprintList(params);
        /*添加指纹*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("fingerprintNumber","1");
//        params.put("fingerprintName","1");
//        params.put("startDate","1");
//        params.put("endDate","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.fingerprintAdd(params);

        /*删除指纹*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("fingerprintId","1");
//        params.put("deleteType","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.fingerprintDelete(params);

        /*清空指纹*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("date","1552555778000");
//        InteDeviceLockUtil.fingerprintClear(params);

        /*清空指纹*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("startDate","1");
//        params.put("endDate","1");
//        params.put("pageNo","1");
//        params.put("pageSize","1");
//        params.put("date","1552557739000");
//        InteDeviceLockUtil.lockRecordList(params);

        /*上传锁记录*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("records","1");
//        params.put("date","1552557739000");
//        InteDeviceLockUtil.lockRecordUpload(params);

        /*检查锁固件是否需要升级*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("records","1");
//        params.put("date","1552558311000");
//        InteDeviceLockUtil.upgradeCheck(params);
        /*再次检测固件是否需要升级*/
//        Map<String,String> params=new HashMap<String, String>();
//        params.put("clientId",InteDeviceLockConfig.CLIENT_ID);
//        params.put("accessToken",InteDeviceLockConfig.ACCESS_TOKEN);
//        params.put("lockId","1");
//        params.put("modelNum","1");
//        params.put("hardwareRevision","1");
//        params.put("firmwareRevision","1");
//        params.put("specialValue","1");
//        params.put("date","1552558311000");
//        InteDeviceLockUtil.upgradeRecheck(params);
//        InteDeviceLockUtil.getTimeSign("2018-01-12 17:07:05","yyyy-MM-dd HH:mm:ss");
        //获取时间
//            InteDeviceLockUtil.getTimeAfter(System.currentTimeMillis(),60*60*1000,"yyyy-MM-dd HH:mm:ss");
        //判断当前时间是否在08:30---20:00
//        String format = "HH:mm:ss";
//        SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss");
//        String now = sf.format(new Date());
//        Boolean iFBill=false;//是否需要账单
//        try {
//            Date nowTime = sf.parse("09:00:00");
//            Date startTime = sf.parse("08:30:00");
//            Date endTime = sf.parse("20:00:00");
//            iFBill=DateUtils.isEffectiveDate(nowTime,startTime,endTime);
//            System.out.println("iFBill:"+iFBill);
//        } catch (java.text.ParseException e) {
//            log.debug("时间转换错误");
//        }

    }
}